----------------------------------Spell Variables--------------------------------------
SPELL.m_iSpellID = 48442 -- Whatever value you want as long as it doesn't override any other spells' IDs.
SPELL.m_iRange = 0
SPELL.m_sName = "Quick Slide"
SPELL.m_sToolTip = [[Causes you to slide
					backwards rapidly. Reactivating
					this ability moves you forwards
					the same distance.]]
SPELL.m_sIcon = "devin/blackbetty/spells/warrior/shieldregen.png"
SPELL.m_bRequiresTarget = false
SPELL.m_iCoolDown = 1
SPELL.m_iManaCost = 2
SPELL.m_iSpellType = SPELLTYPE_MOBILITY

---------------------------------------------------------------------------------------

local range = 100
local weapondamage = 10
local uppercut_time = false

function SPELL:Cast( pl, target )
	pl:EmitSound("devin/blackbetty/weapons/ShieldWall.wav", 160, 100)
	pl:SetVelocity(pl:GetVelocity()*-1)
	ParticleEffectAttach( "whirlwind", PATTACH_POINT_FOLLOW, pl, pl:LookupAttachment("rightfoot"))
	ParticleEffectAttach( "whirlwind", PATTACH_POINT_FOLLOW, pl, pl:LookupAttachment("leftfoot"))
	local subtractedvectors = (pl:GetPos()) - (pl:GetPos() + pl:GetAngles():Forward()*512)
	local subtractedvectorsnorm = (pl:GetPos()) - (pl:GetPos() + pl:GetAngles():Forward()*512)
	subtractedvectorsnorm:Normalize()
	pl:SetPos(pl:GetPos() + Vector(0, 0, 16))
	pl:SetVelocity(-(subtractedvectorsnorm*(4*subtractedvectors:Length()+128)))
	timer.Simple(0.2, function()
		ParticleEffect( "impact_light_damage", pl:GetPos(), Angle(0,0,0), pl )
		pl:SetVelocity(pl:GetVelocity()*-1)
		pl:EmitSound("devin/blackbetty/weapons/Exorcism.wav", 150, 90)
		local modeleffect = ents.Create("prop_dynamic")
		modeleffect:SetMoveParent(pl)
		modeleffect:SetPos(pl:GetPos() + Vector(0, 0, -38))
		modeleffect:SetAngles(pl:GetAngles())
		modeleffect:SetLocalAngles(Angle(0, 0, 0))
		modeleffect:SetModel(Model("models/XQM/Rails/gumball_1.mdl"))
		modeleffect:SetRenderMode(RENDERMODE_TRANSALPHA)
		modeleffect:SetColor(Color(185, 185, 0, 230))
		modeleffect:DrawShadow( false )
		modeleffect:Spawn()
		modeleffect:Activate()
		local sequence = modeleffect:LookupSequence("idle")
		modeleffect:SetSequence(sequence)
		modeleffect:SetPlaybackRate(1.5)
		local inc = 60
		timer.Create(""..pl:GetName().."holyexplosionscale", 0.00625, 40, function()
			inc = inc - 1
			if(inc > 0)then
				modeleffect:SetModelScale( modeleffect:GetModelScale() * 1.15, 0 )
				modeleffect:Fire( "alpha", inc * 4, 0 )
			else
				modeleffect:Remove()
			end
		end)
		local whirlRadius = ents.FindInSphere(pl:GetPos(), 240)
		for i, s in ipairs(whirlRadius)do
			if(s and s:EntIndex() != pl:EntIndex() and s:IsPlayer() or s:IsNPC() or s:GetClass() == "npc_rpgdm")then
				self:Effect(pl, s)
			end
		end
	end)
end

function SPELL:Effect(pl, target)
	if(target:EntIndex() != pl:EntIndex())then
		if(target:IsPlayer() && target:Team() == pl:Team())then
			self:DealDamage(-10, -10, pl, target, DMG_GENERIC)
		else
			self:DealDamage(10, 10, pl, target, DMG_GENERIC)
		end
		ParticleEffect( "impact_light_damage", target:GetPos(), Angle(0,0,0), pl )
	end
end


